package 数组的单调和;

public class 数组的单调和 {

	public static void main(String[] args) {

	}

	public int calcMonoSum(int[] A, int n) {
		int r = 0;
		for (int i = 0; i < A.length; i++)
			r += f(A, i);
		return r;
	}

	public static int f(int[] a, int idx) {
		int r = 0;
		for (int i = 0; i < idx; i++)
			r += a[i] <= a[idx] ? a[i] : 0;
		return r;
	}

}
